//package com.ttg.web.dao.Impl;
//
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.ttg.common.enums.IntervalTypeEnum;
//import com.ttg.model.pojo.CostManageCostGrading;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.ttg.web.dao.CostManageCostGradingDao;
//import org.springframework.stereotype.Service;
//
//import java.time.LocalDateTime;
//import java.util.List;
//import java.util.Objects;
//
///**
// * (TblCostManageCostGrading) daoImpl
// *
// * @author chenyou
// * @datetime 2025-10-10 17:09:52
// */
//@Service
//public class CostManageCostGradingDaoImpl extends ServiceImpl<CostManageCostGradingMapper, CostManageCostGrading> implements CostManageCostGradingDao {
//
//    @Override
//    public CostManageCostGrading getByUnique(String intervalType, String year, String month, Integer lowerBound, Integer upperBound, Integer mctDimType, Integer gradingNo) {
//        LambdaQueryWrapper<CostManageCostGrading> wrapper = new LambdaQueryWrapper<>();
//        wrapper.eq(CostManageCostGrading::getCmcgIntervalType,intervalType);
//        wrapper.eq(CostManageCostGrading::getCmcgMctDimType,mctDimType);
//        wrapper.eq(CostManageCostGrading::getCmcgGradingNo,gradingNo);
//        if(IntervalTypeEnum.月度区间.getValue().equals(intervalType)){
//            wrapper.eq(CostManageCostGrading::getCmcgYear,year);
//            wrapper.eq(CostManageCostGrading::getCmcgMonth,month);
//
//        }else if(IntervalTypeEnum.累计区间.getValue().equals(intervalType)){
//            wrapper.eq(CostManageCostGrading::getCmcgYear,year);
//            wrapper.ge(CostManageCostGrading::getCmcgLowerBound,lowerBound);
//            wrapper.le(CostManageCostGrading::getCmcgUpperBound,upperBound);
//        }
//        return getOne(wrapper);
//    }
//
//    @Override
//    public void saveOrUpdateBatch(List<CostManageCostGrading> list) {
//        for(CostManageCostGrading body:list){
//            CostManageCostGrading old = getByUnique(body.getCmcgIntervalType(),body.getCmcgYear(),body.getCmcgMonth(),body.getCmcgLowerBound(),body.getCmcgUpperBound(),body.getCmcgMctDimType(),body.getCmcgGradingNo());
//            if(Objects.isNull(old)){
//                body.setCmcgAddTime(LocalDateTime.now());
//                body.setCmcgUpdateTime(LocalDateTime.now());
//                save(body);
//            }else{
//                body.setCmcgId(old.getCmcgId());
//                body.setCmcgUpdateTime(LocalDateTime.now());
//                updateById(body);
//            }
//        }
//
//    }
//}
//
